home *** CD-ROM | disk | FTP | other *** search
- ADDING USER-DEFINED EXTENSIONS TO WCL
- -------------------------------------
- Over the past few months, I have received incessant requests for me to
- provide support for user extensions to my command line processor for Windows
- (WCL) - some people want to implement a telnetd for winsock, using WCL as
- the basic CLI, and others just want to be able to extend the command set.
- I have finally decided to provide a limited interface or hook to WCL
- for Windows programmers so that they can add their own commands. This
- provides endless opportunities for extending the command set which I have
- provided as internal commands, since such user extensions are treated as
- internal commands by WCL.
-
- I explain the basic structure of the interface below. I have decided as
- a preliminary measure to make a working copy of the beta shareware
- version available to programmers who want to have a look at the interface
- I have provided. This consists only of BIGWCL.EXE and the files needed
- to make it work, plus the documentation for the interface I have provided.
- If you are interested, and can receive a large UUencoded file (305kb)
- then you can e-mail me. I will send a copy to the first 20 respondents.
- If you hear nothing from me, then please assume that you were not among
- the first 20 replies I received - sorry, but I cannot reply to every one
- and I will not make this more publicly available, since this feature is
- still only at a beta stage. Whether I will go on and add this feature to the
- release versions depends entirely on the feedback I receive.
-
- Please note that the standard shareware restrictions apply to anything I
- send to anybody. You can test it for 30 days. After that, you are required
- to please register it, or delete it from your disks. The only thing that
- is beta in it is this interface I am trying to provide for programmers.
-
- The interface
- -------------
- The interface I have provided is very simple, as long as the rules are
- adhered to. It revolves around a DLL which must be created by the user, and
- which exports only 1 function (actually, it can export as many functions as
- it likes, but WCL will refer to only ONE named function).
-
- Rules
- -----
- 1. The DLL must be called WCL_EXT.DLL, and must be compiled with the FAR
- directive (and for C/C++ programmers, it must be "FAR Pascal").
- 2. The function which WCL will interface to takes a null terminated string
- as the ONLY parameter, and returns an INTEGER. It must be defined,
- EXACTLY thus;
-
- [a] In Borland PASCAL
- Function UserProc (Var Parm : PChar) : Integer;
- [b] In C/C++
- int UserProc (LPSTR Parm); (or is it *Parm)?
-
- I don't have a clue as to how you will do this in VBasic. If anyone
- knows, please do let me know.
-
- 3. In the EXPORTS section of the DLL, the function must be given an ordinal
- index number of 1
-
- eg, in Pascal
- exports
- UserProc index 1;
-
- 4. You cannot do any output to the WCL window in your DLL (i.e., no
- Writeln() in Pascal or output to STDOUT in C/C++) - all communications
- with the user during the operation of your functions must be by Windows
- dialog boxes.
- 5. If you want the output from the commands to be echoed in the WCL window,
- you have to do 2 things;
- [a] Let function UserProc return ZERO or higher
- [b] Put whatever you want to be output at the WCL window into the
- null terminated string that was passed as a parameter to
- UserProc
-
- If the function returns 0 or higher, WCL will re-direct whatever it finds
- in "Parm" to the WCL window, when your function returns. Note that the
- output in the string is dumped to the WCL window exactly as it is. If you
- want a formatted output, you have to format the null terminated string
- yourself, in your function (eg by inserting carriage returns after every
- 60 characters).
-
- If the function returns a value less than 0 (eg -1) then nothing will be
- written to the WCL window.
-
- 6. When you want to call one of your user defined commands, you type
- "EXT" or "USERPROC" at the WCL prompt, followed by your own commands.
- Prefixing "EXT" to a command is the way to tell WCL to pass on the
- command to your user defined function. When WCL finds "EXT" or
- "USERPROC", it will pass whatever appears afterward to your DLL,
- exactly as it appears.
-
- e.g, if you have a new command "MYPROG", to call it, you would type
- "EXT MYPROG" from the WCL prompt.
-
- Comments
- --------
- I have decided to use this method of providing hooks for other programmers
- for a number of reasons. First, it is straightforward. Secondly, it does not
- add much to the bulk of WCL itself - something I have to take seriously,
- because most of my users are not programmers and are not interested in this
- feature.
-
- I expect the function UserProc() to be used as a "container" or "interface"
- function only - although you can use it as you please. What I really
- envisage is that programmers can define any number of functions and commands
- in their WCL_EXT.DLL, and that they will use the function UserProc() as
- their "command line", which they will then parse, and then call other
- functions in the DLL or elsewhere as may be necessary. Check this pseudo
- code;
-
- {------------------------------------------------------------}
- function UserProc (Var Parm : PChar) : integer;
- begin UserProc
-
- if Parm = "SHUTDOWN" then call function ONE
- else
- if Parm = "OK" then call function TWO
- else
- if Parm = "MAKE_NOISE" then call MessageBeep (0)
- else
- {etc, etc, etc }
-
- Return -1
- end UserProc
- {-----------------------------------------------------------}
-
- For those programmers who need it, I have provided an interface to a number
- of functions in WCLCODE2.DLL, which comes standard with WCL. These are
- string functions - to break up the "Parm" string parameter into as many
- substrings as are found in it (up to 20) and return the number of such
- substrings. This way, it is easy to parse the parameter passed to the
- UserProc function.
-
- eg if you passed "BPC -CW MYPROG.PAS /$F+ /L /$N+" in "Parm", calling the
- function BreakString() will return 6 (there are 6 substrings in this string)
- and the 6 substrings will be returned in an array.
-
- These string functions were originally written to process Pascal type
- strings only, but I have added equivalents for null terminated strings so
- that C/C++ users can use the same functions. I have provided a Borland
- Pascal interface unit (WCL_INT.PAS) for these functions, which contains all
- the declarations, and the ordinal numbers of the functions, etc. Pascal
- programmers can just add this unit to their USES clause, and start using the
- functions right away. C/C++ programmers will have to create a header file
- using the supplied information, and also a LIB file for WCLCODE2.DLL, using
- their compiler's IMPLIB utility. If anybody does this successfully, please
- send me a copy of the header file, and of the LIB file (indicating what
- compiler this was created for).
-
- As for VBasic programmers - sorry, I don't have a clue as to how you would
- go about using these functions.
-
- I have also provided a sample WCL_EXT.DLL, with the Pascal source code to it
- (WCL_EXT.PAS), which uses the parsing functions I referred to above. This is
- supplied just as an example - to see what types of things you could do in
- your DLL - but also because I need to provide a dummy DLL of that name,
- since WCL now contains a reference to WCL_EXT.DLL.
-
- When you create your own DLL, just copy it over the one that is supplied.
-
- Thanks for your attention and bye.
-
- --
- The Chief
- ---------
- Dr. Abimbola Olowofoyeku ( The African Chief)
- Keele University ( All opinions are *not* personal and *do*)
- England. ( reflect the views of the whole world.)
-
- Email: laa12@keele.ac.uk
- chief@mep.com
-
- Tel : (0782) 621111
- Fax : (0782) 583228
- ---------------------------------------------------
- "Do you see a man that is wise in his own conceit?
- There is more hope for a fool than for him."
- King Solomon.
- ---------------------------------------------------
-
-